﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;

namespace dotsoftRAID_Controller
{
    public class Logging
    {
        public static StreamWriter Initialize()
        {
            string logFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "controller.log");

            StreamWriter consoleOut = new StreamWriter(logFile);
            consoleOut.AutoFlush = true;

            return consoleOut;
        }

        public static void EnterMethod()
        {
            StackTrace stack = new StackTrace();
            StackFrame callingMethod = stack.GetFrame(1);

            Console.WriteLine(string.Format("[{0}: Enter Method '{1}']", DateTime.Now, callingMethod.GetMethod().Name));
        }

        public static void ExitMethod()
        {
            StackTrace stack = new StackTrace();
            StackFrame callingMethod = stack.GetFrame(1);

            Console.WriteLine(string.Format("[{0}: Exit Method '{1}']", DateTime.Now, callingMethod.GetMethod().Name));
        }
    }
}
